<?php
class Admin_Form_NewsItem_ValidateFileAttach{
	
	public static function validate($arrParam = null, $options = null){
		$upload = new Zend_File_Transfer_Adapter_Http();
	
		$fileInfo = $upload->getFileInfo('file_attach');
		$fileName = $fileInfo['file_attach']['name'];
		if(!empty($fileName)){
			$options = array('rar','zip','gz','pdf','xls','doc');
			$upload->addValidator('Extension',true,$options,'file_attach')
			 	   ->addValidator('FilesSize',true,array('min'=>'1kb','max'=>'10000kb'),'file_attach');
			 	  // ->addValidator(new Zend_Validate_StringLength(array('min'=>2,'max'=>100,'encoding'=>'utf-8')),true)	
			if(!$upload->isValid('file_attach')){
				$message = $upload->getMessages();
				$error = current($message);							
			}
		}
		return $error;	
	}	
}